feat: add artifact demo example and defineArtifact() API#408
Open
ankit-thesys wants to merge 5 commits intothesysdev:mainfrom
Open
feat: add artifact demo example and defineArtifact() API#408ankit-thesys wants to merge 5 commits intothesysdev:mainfrom
ankit-thesys wants to merge 5 commits intothesysdev:mainfrom
Conversation
New example app demonstrating the OpenUI artifact system for displaying AI-generated code in a resizable side panel. - Custom ArtifactCodeBlock genui component with inline preview and artifact panel view - Extends openuiChatLibrary with artifact-specific component and prompt rules - Syntax highlighting via react-syntax-highlighter (Prism, vscDarkPlus) - Copy-to-clipboard, language badges, filename headers - Multiple artifacts per conversation, one active at a time - Code-focused conversation starters (React, Python, CSS, SQL)
Adds Artifact() to @openuidev/react-ui — a factory that returns a ComponentRenderer with automatic useId, useArtifact, and ArtifactPanel wiring. Consumers provide preview/panel render functions; no manual artifact boilerplate needed. No changes to lang-core or react-lang. - react-ui: new Artifact() function with ArtifactControls injection - example: migrate ArtifactCodeBlock to use Artifact() - example: remove artifactId from schema and prompt, simplify InlinePreview Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
f41c24f to
f53ff2a
Compare
Explains the artifact system for consumers — Artifact() factory, ArtifactControls, layout setup, headless hooks, and manual wiring escape hatch. Placed under Chat Layouts after BottomTray. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
examples/openui-artifact-demo/) — Full Next.js app demonstrating the OpenUI artifact system for displaying AI-generated code in a resizable side paneldefineArtifact()API (packages/react-ui/src/artifact/) — New first-class function that eliminates artifact component boilerplate by auto-wiringuseId,useArtifact, andArtifactPanelArtifactMetametadata onDefinedComponentinlang-core— Enables prompt generation to annotate artifact components and framework introspectionChanges
New:
defineArtifact()API (react-ui)Consumers provide just
previewandpanelrender functions — no manual ID generation, hook wiring, orArtifactPanelcomposition:Package changes
ArtifactMetatype, optionalartifact?field onDefinedComponent,[artifact]tag in prompt generationartifactfield indefineComponent, re-exportArtifactMetadefineArtifact()function withArtifactControlsinjection, exported from@openuidev/react-uiArtifact demo example
ArtifactCodeBlockcomponent with inline preview card + full syntax-highlighted panel viewopenuiChatLibrarydefineArtifact()APITest plan
pnpm buildpasses across all packagespnpm testin lang-core, react-headless)pnpm generate:promptproduces correct system prompt with[artifact]tag🤖 Generated with Claude Code